package com.ebt.m.customer.view;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

import com.ebt.m.R;
import com.ebt.m.proposal_v2.widget.dialog.EBTDialogBase;


/**
 * @author Damon
 * @date 2017/12/1
 */

public class Dialog4CustomerAttachmentRename extends EBTDialogBase {
    //1上传文件处修改名称-可以跟原文件名相同
    //2重命名处进入-相同的文件名会提示
    private int from;
    private Context mContext;

    public static Dialog4CustomerAttachmentRename netInstance(String fileName) {
        Dialog4CustomerAttachmentRename dialog4CustomerAttachment = new Dialog4CustomerAttachmentRename();
        Bundle extras = new Bundle();
        extras.putString(Arg_Data, fileName);
        dialog4CustomerAttachment.setArguments(extras);
        return dialog4CustomerAttachment;
    }

    @Override
    public void init() {
        mContext = getContext();
        String fileName = (String) getArguments().getSerializable(Arg_Data);
        if (fileName == null) {
            return;
        }
        View contentView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_attachment_filename, null, false);
        EditText textView = (EditText) contentView.findViewById(R.id.customer_add_attachment_dialog_file_name_et);
        String fileNameWithooutSuffix = "";
        if (fileName.contains(".")) {
            fileNameWithooutSuffix = fileName.substring(0, fileName.lastIndexOf("."));
        } else {
            fileNameWithooutSuffix = fileName;
        }
        textView.setText(fileNameWithooutSuffix);
        textView.setSelection(textView.getText().length());
        addDialogBody(contentView);
    }

}
